package com.sk.bilibili.view.fragment.rank;

import com.alibaba.android.vlayout.DelegateAdapter;
import com.sk.bilibili.adapter.vlayout.rank.VideoSetAdapter;
import com.sk.bilibili.bean.Focus;
import com.sk.bilibili.bean.VideoSet;
import com.sk.bilibili.callBack.FullVideoSetCallBack;
import com.sk.bilibili.model.fragment.rank.VideoSetModel;
import com.sk.bilibili.view.activity.MemberActivity;
import com.sk.bilibili.view.activity.VideoSetActivity;
import com.sk.bilibili.view.diy.bottomDialog.LaterBottomDialog;
import com.sk.bilibili.view.fragment.BaseTypeFragment;

import java.util.List;

public class FullVideoSetFragment extends BaseTypeFragment<VideoSetModel> implements FullVideoSetCallBack {

    public FullVideoSetFragment(Integer typeId) {
        super(typeId);
        laterBottomDialog=new LaterBottomDialog();
    }

    private LaterBottomDialog laterBottomDialog;

    private VideoSetAdapter videoSetAdapter;

    @Override
    protected void initAdapter(DelegateAdapter adapter) {
        videoSetAdapter = new VideoSetAdapter(getContext(), this);
        adapter.addAdapter(videoSetAdapter);
    }

    @Override
    public void onRefresh() {
        model.refresh(typeId);
    }

    @Override
    public void onClickVideoSet(Integer id) {
        VideoSetActivity.start(getContext(), id);
    }

    @Override
    public void onClickMember(Integer id) {
        MemberActivity.start(getContext(), id);
    }

    @Override
    public void onClickMore(Integer id) {
        laterBottomDialog.show(getChildFragmentManager(),id);
    }

    public void refreshSuccess(List<VideoSet> videoSets) {
        videoSetAdapter.setData(videoSets);
        cancelRefresh();
    }

    public void onFocusClick(Integer id) {
        model.switchFocus(id);
    }

    public void switchFocusSuccess(Focus focus) {
        toast(focus==null?"取消关注成功":"关注成功");
    }

}